<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>项目管理</title>


    <link type="text/css" href="/TopJUI/topjui/css/topjui.core.min.css" rel="stylesheet">
    <link type="text/css" href="/TopJUI/topjui/themes/default/topjui.green.css" rel="stylesheet" id="dynamicTheme"/>
    <!-- FontAwesome字体图标 -->
    <link type="text/css" href="/TopJUI/topjui/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- jQuery相关引用 -->
    <script type="text/javascript" src="/TopJUI/topjui/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/TopJUI/topjui/plugins/jquery/jquery.cookie.js"></script>
    <!-- TopJUI框架配置 -->
    <script type="text/javascript" src="/TopJUI/static/public/js/topjui.config.js"></script>
    <!-- TopJUI框架核心-->
    <script type="text/javascript" src="/TopJUI/topjui/js/topjui.core.min.js"></script>
    <!-- TopJUI中文支持 -->
    <script type="text/javascript" src="/TopJUI/topjui/js/locale/topjui.lang.zh_CN.js"></script>

    <script type="text/javascript" src="/pages/js/moment.min.js"></script>
    <script type="text/javascript" src="/pages/js/layer/layer.js"></script>
    <script type="text/javascript" src="/pages/js/util.js"></script>

    <script type="text/javascript" src="/pages/js/base-loading.js"></script>
    <script type="text/javascript" src="/pages/js/shuoheUtil.js"></script>

    <style type="text/css">
        html, body{ margin:0; height:100%; }
    </style>

</head>
<body class="easyui-layout">
  <script type="text/javascript">
  </script>

    <div data-options="region:'center',iconCls:'icon-reload',title:'',split:true" style="width:100%;height: 100%">
        <table id="dg" class='easyui-datagrid' style="width:100%;height:100%" title="" data-options="
                  rownumbers:true,
                  singleSelect:true,
                  autoRowHeight:false,
                  pagination:true,
                  fitColumns:false,
                  striped:true,
                  checkOnSelect:true,
                  selectOnCheck:true,
                  collapsible:true,
                  toolbar:'#tb',
                  pageSize:20">
            <thead>
              <tr href="#">
<!--                     <th field="id" align="center" hidden ="true">id</th>
                    <th field="project_id" align="center">项目编号</th>
                    <th field="project_name">项目名称</th>
                    <th field="contract_id" align="center">合同编号</th>
                    <th field="contract_sign_date">合同签署日期</th>
                    <th field="contract_cycle_day" align="center">合同周期</th>
                    <th field="contract_deliver_date">合同交付日期</th>
                    <th field="company_name" align="center">公司名称</th>
                    <th field="project_url">项目地址</th>
                    <th field="xx">查看</th> -->
              </tr>
            </thead>
          </table>
          <div id="tb" style="height:35px">            
            <a id='btnInsert' href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fa fa-plus',plain:true" onclick="add()" style="margin-left: 30px">新增</a>
            <a id='btnUpdate' href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fa fa-pencil',plain:true" onclick="edit()">修改</a>
            <a id='btnEdit' href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fa fa-hand-pointer-o',plain:true" onclick="view()">查看</a>                    
            <a id='btnDelete' href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fa fa-trash',plain:true" onclick="dele()">删除</a>
<!--             <a id='btnInsert' href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'fa fa-user-plus',plain:true" onclick="personnel()">项目人员</a>        -->     
            <form id="queryForm" class="search-box">
                  <input class="easyui-textbox" id='equipment_id' data-options="prompt:'公司名称'">
                  <input class="easyui-textbox" id='equipment_name' data-options="prompt:'公司地址'">
                  <a id='btnQuery' href="#" class="easyui-linkbutton" btnCls='topjui-btn-normal' plain="true" iconCls="fa fa-search" onclick="functionQuery()" style="margin-left: 0px">搜索</a>          
                  <a id='btnClear' href="#" class="easyui-linkbutton" btnCls='topjui-btn-normal' plain="true" iconCls="fa fa-refresh" onclick="functionClear()" style="margin-left: 0px">清除</a>                     
              </form>            
          </div>
       </div>
    </div>




  <script type="text/javascript">
    $(function(){
    	loadDg();
    });
    
    function loadDg() {
        $('#dg').datagrid({
            url: '/develop/url/getUrl.do',
            queryParams: {
                'name': 'getProjectListForDatagraid'//,
                // 'equipment_id': $('#equipment_id').textbox('getValue'),
                // 'equipment_name': $('#equipment_name').textbox('getValue'),
                // 'use_department': $('#use_department').textbox('getValue'),
                // 'actual_name': $('#actual_name').textbox('getValue')
            },
            method: 'get',
            columns:
              [[

                  {field:'id',title:'id',hidden:true},
                  {field:'project_id',title:'项目编号'},
                  {field:'project_name',title:'项目名称'},
                  {field:'contract_id',title:'合同编号'},
                  {field:'contract_sign_date',title:'合同签署日期'},
                  {field:'contract_cycle_day',title:'合同周期'},
                  {field:'contract_deliver_date',title:'合同交付日期'},
                  {field:'company_name',title:'公司名称'},
                  {field:'project_url',title:'项目地址'}
                  // {
                  //   field:'xx',title:'查看',
                  //   formatter: function(value,row,index)
                  //   {
                  //     return '<a name="opera" class="easyui-linkbutton" ></a>'  
                  //   }
                  // }
              ]],
              onLoadSuccess:function(data)
              {
                // $("a[name='opera']").linkbutton({text:'查看',plain:false,iconCls:'fa fa-link'}); 
                // $(this).datagrid("autoSizeColumn")
                // $("a[name='opera']").bind('click', function(){    

                //     var row = $('#dg').datagrid('getSelected');
                //     if (row == null) {
                //         layerMsgCustom('必须选择一条数据');
                //         return;
                //     }
                //     if(row.project_url == null)
                //     {
                //         layerMsgCustom('选择的项目没有录入项目地址');
                //         return;
                //     }

                //     top.layer.open({
                //         type: 2,
                //         title: '新增设备',
                //         shadeClose: false,
                //         shade: 0.3,
                //         maxmin: true, //开启最大化最小化按钮s
                //         area: ['800px','400px'],
                //         content: row.project_url
                //     });
                // });    
              }
        })
    }

    // function viewProjectWeb(val,row,index)
    // {
    //     return "<a href='javascript:void(0)' class='easyui-linkbutton' data-options='iconCls:'fa fa-user-plus',plain:true' onclick='personnel()'>查看</a>"
    // }

    // function fomatterUrl(val,row,index)
    // {
    //   return '<a href="javacript:void(0);" onclick="openNewWindows('+val+')">'+val+'</a>';
    // }
    // function openNewWindows(url)
    // {
    //   // top.layer.open({
    //   //     type: 2,
    //   //     title: '新增设备',
    //   //     shadeClose: false,
    //   //     shade: 0.3,
    //   //     maxmin: true, //开启最大化最小化按钮s
    //   //     area: ['800px','400px'],
    //   //     content: url
    //   // });
    // }

	</script>




</body>
</html>
<script type="text/javascript">
    function add() {
      layer.open({
          type: 2,
          title: '新增设备',
          shadeClose: false,
          shade: 0.3,
          maxmin: true, //开启最大化最小化按钮s
          area: ['800px','400px'],
          content: 'form/addProject.jsp'
      })
    }
  function view()
  {
      var row = $('#dg').datagrid('getSelected');
        if(row == null)
        {
          layerMsgCustom('必须选择一条数据');
          return;
        }

        layer.open({
            type: 2,
            title: '查看设备',
            shadeClose: false,
            shade: 0.3,
            maxmin: true, //开启最大化最小化按钮
            area: ['800px','400px'],
            content: 'form/viewProject.jsp?id=' + row.id+'&id='+row.id
        })
  }

    function edit() {

        var row = $('#dg').datagrid('getSelected');
        if (row == null) {
            layerMsgCustom('必须选择一条数据');
            return;
        }

        layer.open({
            type: 2,
            title: '修改设备',
            shadeClose: false,
            shade: 0.3,
            maxmin: true, //开启最大化最小化按钮
            area: ['800px','400px'],
            content: 'form/editProject.jsp?id=' + row.id+'&id='+row.id
        })
    }
    function dele() {
        var row = $('#dg').datagrid('getSelected');
        if (row == null) {
            layerMsgCustom('必须选择一条数据');
            return;
        }
        //删除操作属于危险操作，给出提示
        $.messager.confirm('友情提示', '您确定要删除这条数据吗?', function(r) {
            if (r) {
                shuoheUtil.layerTopMaskOn();
                $.ajax({
                    url: "/pm2/project/project/delete.do",
                    type: "POST",
                    dataType: 'json',
                    data: {
                        'id': row.id
                    },
                    error: function() //失败
                    {
                        shuoheUtil.layerTopMaskOff();
                    },
                    success: function(data) //成功
                    {
                        updateSuccess();
                        shuoheUtil.layerTopMaskOff();
                        if(data.result)
                        {
                            shuoheUtil.layerMsgOK(data.describe);
                        }
                        else
                        {
                            shuoheUtil.layerMsgError(data.describe);
                        }
                    }
                });
            }
        });
    }


  function updateSuccess()
  {
    $('#dg').datagrid('reload');

  }
  
  
  function functionQuery() {
	    loadDg();
	  }
	  function functionClear() {
	    $('#equipment_id').textbox('clear');
	    $('#equipment_name').textbox('clear');
	    $('#use_department').textbox('clear');
	    $('#actual_name').textbox('clear');
	    loadDg();
	  }


</script>
